import org.junit.Test;
import org.apache.commons.lang.math.RandomUtils;


public class testXoverStartEnd {
    static final int BATCH_SIZE = 100;

    @Test public void testStartEnd(){
        int first = RandomUtils.nextInt(10000);
        int last = RandomUtils.nextInt(10000) + first;
        System.out.println("First: " + first + "  / Last: " + last);
        int current = first;

        int start = current;
        int end;
        while(current <= last){
            end = (current + BATCH_SIZE > last) ? last : current + BATCH_SIZE;
            doStuff(start, end);
            current = end + 1;
        }
        assertTrue(current == last);
    }
    
    private void doStuff(int start, int end){
        System.out.println("Start: " + start +  " end: " + end);
        for(int i = start; start <= end; ++start){
            try {
                Thread.sleep(10);
            }
            catch(InterruptedException e){
                System.err.println("Interrupted");
            }
        }
    }
}
